package libs

import (
	"github.com/gin-gonic/gin"
	"github.com/jinzhu/configor"
)

type DbConfig struct {
	Host    string
	DbName  string
	User    string
	Pass    string
	Charset string
}

type RedisConfig struct {
	Host string
	Select int
	Password string
	Prefix string
}

type Config struct {
	Debug bool
	Token string
	Port string
	DB DbConfig
	Redis RedisConfig
}

var config = &Config{}

func init()  {
	configor.Load(config, "config.yml")

	if config.Debug {
		gin.SetMode(gin.DebugMode)
	} else {
		gin.SetMode(gin.ReleaseMode)
	}
}

func GetConfig() *Config {
	return config
}
